home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / checkline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-08-02  |  1.4 KB  |  60 lines

  1. /*
  2.    checkline: check the input line just read in against what we expect
  3.    to find and report any problems.  Actually, most of the work is done
  4.    by check_item.  We just identify what needs to be checked.
  5.  
  6.    Kenneth Ingham
  7.  
  8.    Copyright (C) 1987 The University of New Mexico
  9. */
  10.  
  11. #include "defs.h"
  12. #include "y.tab.h"
  13.  
  14. checkline(cmd, line, prev_res, hf)
  15. struct cmd_st *cmd;
  16. char *line;
  17. struct old_cmd_st *prev_res;
  18. FILE *hf;
  19. {
  20.     extern int line_ok;
  21.     struct change_fmt_st *cf;
  22.     struct out_fmt_st of;
  23.     char key_val[MAX_STR];
  24.     char *cmd_name;
  25.  
  26.     cmd_name = ((cmd->alias != NULL) ? cmd->alias : cmd->pipeline);
  27.         
  28.     save_key(cmd, line, key_val, hf); /* side effect: return key value */
  29.  
  30.     /* for each change format item */
  31.     line_ok = True;
  32.     for (cf=cmd->change_fmt; cf; cf=cf->next) {
  33.         /* find the output format entry for this item */
  34.         if (!find_of(cf->name, cmd->out_fmt, &of)) {
  35.             fprintf(stderr, "Warning: %s appears in change list ",
  36.                 cf->name);
  37.             fprintf(stderr, "but not in output format for %s\n",
  38.                 cmd_name);
  39.             continue;
  40.         }
  41.  
  42.         /*
  43.            check the item, depending on which type of output
  44.            format we have.
  45.         */
  46.         switch (cmd->out_fmt->type) {
  47.             case RELATIVE:
  48.                 check_rel_item(prev_res, of.out_fmt.rel_fmt,
  49.                     key_val, line, cf, cmd_name, hf);
  50.                 break;
  51.             case COLUMN:
  52.                 check_col_item(prev_res, of.out_fmt.col_fmt,
  53.                     key_val, line, cf, cmd_name, hf);
  54.                 break;
  55.         }
  56.     }
  57.     if (!line_ok)
  58.         printf("---------\n");
  59. }
  60.